from lunch_date.models import LunchAppointment
from django.db.models import Q

def find_appointment (employee_id):
    appointments = LunchAppointment.objects.get(Q(attendee1_id=employee_id) | Q(attendee2_id=employee_id))
    return appointments
    
def insert_appointment(creator, attendee1_id, attendee2_id, location, status, appointment_datetime):
    appointment = LunchAppointment(creator=creator, attendee1_id= attendee1_id, 
                                  attendee2_id=attendee2_id, location=location, status=status, 
                                  appointment_datetime=appointment_datetime)
    return appointment.save()

def update_appointment(lunch_id, **fields):
    return LunchAppointment.objects.filter(id=lunch_id).update(**fields)

def delete_appointment(lunch_id):
    lunch_date = LunchAppointment.objects.get(id=lunch_id)
    return lunch_date.delete()
